/*
 * Modificar_Producto.java
 *
 * Created on 14-oct-2008, 10:35:13
 */
package investigaciones_itm.Productos;

import com.sun.rave.faces.data.DefaultSelectItemsArray;
import com.sun.rave.web.ui.appbase.AbstractPageBean;
import com.sun.webui.jsf.component.Body;
import com.sun.webui.jsf.component.Button;
import com.sun.webui.jsf.component.Checkbox;
import com.sun.webui.jsf.component.DropDown;
import com.sun.webui.jsf.component.Form;
import com.sun.webui.jsf.component.Head;
import com.sun.webui.jsf.component.Html;
import com.sun.webui.jsf.component.Label;
import com.sun.webui.jsf.component.Link;
import com.sun.webui.jsf.component.Page;
import com.sun.webui.jsf.component.PanelGroup;
import com.sun.webui.jsf.component.PanelLayout;
import com.sun.webui.jsf.component.StaticText;
import com.sun.webui.jsf.component.Tab;
import com.sun.webui.jsf.component.TabSet;
import com.sun.webui.jsf.component.Table;
import com.sun.webui.jsf.component.TableColumn;
import com.sun.webui.jsf.component.TableRowGroup;
import com.sun.webui.jsf.component.TextArea;
import com.sun.webui.jsf.component.TextField;
import com.sun.webui.jsf.model.Option;
import com.sun.webui.jsf.model.SingleSelectOptionsList;
import javax.faces.FacesException;
import investigaciones_itm.RequestBean1;
import investigaciones_itm.SessionBean1;
import investigaciones_itm.ApplicationBean1;
import itm.bo.productos.AtributosBO;
import itm.bo.productos.ProductosBO;
import itm.vo.administracion.CategoriaProductosVO;
import itm.vo.administracion.ClaseProductoVO;
import itm.vo.administracion.TipoVO;
import itm.vo.prodructos.AtributosVO;
import itm.vo.prodructos.ProductoVO;
import java.sql.Date;
import java.util.ArrayList;
import java.util.List;
import javax.faces.component.UISelectItems;
import javax.faces.component.html.HtmlMessages;
import javax.faces.component.html.HtmlPanelGrid;
import javax.faces.component.html.HtmlSelectOneListbox;
import javax.faces.context.FacesContext;
import javax.faces.event.ValueChangeEvent;
import javax.faces.model.SelectItem;
import javax.servlet.http.HttpSession;

/**
 * <p>Page bean that corresponds to a similarly named JSP page.  This
 * class contains component definitions (and initialization code) for
 * all components that you have defined on this page, as well as
 * lifecycle methods and event handlers where you may add behavior
 * to respond to incoming events.</p>
 *
 * @author Administrador
 */
public class Modificar_Producto extends AbstractPageBean {

    private DropDown dropTipoProducto = new DropDown();
    private DropDown dropCategoria = new DropDown();
    private DropDown dropClase = new DropDown();
    private SingleSelectOptionsList optionTipoProducto = new SingleSelectOptionsList();
    private SingleSelectOptionsList optionCategoria = new SingleSelectOptionsList();
    private SingleSelectOptionsList optionClase = new SingleSelectOptionsList();
    private List<AtributosVO> listaAuxAtributos = new ArrayList<AtributosVO>();
    private HttpSession session;
    private static final String ID_SESSION_MODIFICAR_PRODUCTO = "modificar.producto";
    // <editor-fold defaultstate="collapsed" desc="Managed Component Definition">

    /**
     * <p>Automatically managed component initialization.  <strong>WARNING:</strong>
     * This method is automatically generated, so any user-specified code inserted
     * here is subject to being replaced.</p>
     */
    private void _init() throws Exception {
    }
    private Page page1 = new Page();

    public Page getPage1() {
        return page1;
    }

    public void setPage1(Page p) {
        this.page1 = p;
    }
    private Html html1 = new Html();

    public Html getHtml1() {
        return html1;
    }

    public void setHtml1(Html h) {
        this.html1 = h;
    }
    private Head head1 = new Head();

    public Head getHead1() {
        return head1;
    }

    public void setHead1(Head h) {
        this.head1 = h;
    }
    private Link link1 = new Link();

    public Link getLink1() {
        return link1;
    }

    public void setLink1(Link l) {
        this.link1 = l;
    }
    private Body body1 = new Body();

    public Body getBody1() {
        return body1;
    }

    public void setBody1(Body b) {
        this.body1 = b;
    }
    private Form form1 = new Form();

    public Form getForm1() {
        return form1;
    }

    public void setForm1(Form f) {
        this.form1 = f;
    }
    private PanelGroup groupPanel1 = new PanelGroup();

    public PanelGroup getGroupPanel1() {
        return groupPanel1;
    }

    public void setGroupPanel1(PanelGroup pg) {
        this.groupPanel1 = pg;
    }
    private TabSet tabSet1 = new TabSet();

    public TabSet getTabSet1() {
        return tabSet1;
    }

    public void setTabSet1(TabSet ts) {
        this.tabSet1 = ts;
    }
    private Tab tab1 = new Tab();

    public Tab getTab1() {
        return tab1;
    }

    public void setTab1(Tab t) {
        this.tab1 = t;
    }
    private PanelLayout layoutPanel1 = new PanelLayout();

    public PanelLayout getLayoutPanel1() {
        return layoutPanel1;
    }

    public void setLayoutPanel1(PanelLayout pl) {
        this.layoutPanel1 = pl;
    }
    private Label label6 = new Label();

    public Label getLabel6() {
        return label6;
    }

    public void setLabel6(Label l) {
        this.label6 = l;
    }
    private Label label7 = new Label();

    public Label getLabel7() {
        return label7;
    }

    public void setLabel7(Label l) {
        this.label7 = l;
    }
    private Button buttonGuardar = new Button();

    public Button getButtonGuardar() {
        return buttonGuardar;
    }

    public void setButtonGuardar(Button b) {
        this.buttonGuardar = b;
    }
    private Label label9 = new Label();

    public Label getLabel9() {
        return label9;
    }

    public void setLabel9(Label l) {
        this.label9 = l;
    }
    private Label label11 = new Label();

    public Label getLabel11() {
        return label11;
    }

    public void setLabel11(Label l) {
        this.label11 = l;
    }
    private Label label12 = new Label();

    public Label getLabel12() {
        return label12;
    }

    public void setLabel12(Label l) {
        this.label12 = l;
    }
    private TextArea textAreaDesModi = new TextArea();

    public TextArea getTextAreaDesModi() {
        return textAreaDesModi;
    }

    public void setTextAreaDesModi(TextArea ta) {
        this.textAreaDesModi = ta;
    }
    private Label label13 = new Label();

    public Label getLabel13() {
        return label13;
    }

    public void setLabel13(Label l) {
        this.label13 = l;
    }
    private TextArea textAreaResutModi = new TextArea();

    public TextArea getTextAreaResutModi() {
        return textAreaResutModi;
    }

    public void setTextAreaResutModi(TextArea ta) {
        this.textAreaResutModi = ta;
    }
    private Button buttonVolver = new Button();

    public Button getButtonVolver() {
        return buttonVolver;
    }

    public void setButtonVolver(Button b) {
        this.buttonVolver = b;
    }
    private Label label15 = new Label();

    public Label getLabel15() {
        return label15;
    }

    public void setLabel15(Label l) {
        this.label15 = l;
    }
    private Label label16 = new Label();

    public Label getLabel16() {
        return label16;
    }

    public void setLabel16(Label l) {
        this.label16 = l;
    }
    private Label label17 = new Label();

    public Label getLabel17() {
        return label17;
    }

    public void setLabel17(Label l) {
        this.label17 = l;
    }
    private TextArea textAreaBeneModi = new TextArea();

    public TextArea getTextAreaBeneModi() {
        return textAreaBeneModi;
    }

    public void setTextAreaBeneModi(TextArea ta) {
        this.textAreaBeneModi = ta;
    }
    private HtmlSelectOneListbox listboxModiTiPro = new HtmlSelectOneListbox();

    public HtmlSelectOneListbox getListboxModiTiPro() {
        Option[] options;
        listboxModiTiPro = new HtmlSelectOneListbox();
        String idTipoProducto;
        String nombreTipoProducto;

        ProductosBO productosBO = new ProductosBO();

        List<TipoVO> listaTipoProducto = new ArrayList<TipoVO>();

        List collection = new ArrayList();
        collection.add(new SelectItem(0, "-Seleccione un tipo de Producto-"));
        try {
            listaTipoProducto = productosBO.listaTipo();
            options = new Option[listaTipoProducto.size()];
            for (int i = 0; i < listaTipoProducto.size(); i++) {
                idTipoProducto = listaTipoProducto.get(i).getIdTipoProducto();
                nombreTipoProducto = listaTipoProducto.get(i).getNombreTipoProducto();
                options[i] = new Option(idTipoProducto, nombreTipoProducto);
                collection.add(new SelectItem(idTipoProducto, nombreTipoProducto));
            } // end for
            optionTipoProducto.setOptions(options);
            UISelectItems listaMenu = new UISelectItems();
            listaMenu.setValue(collection);
            listboxModiTiPro.getChildren().add(listaMenu);
        } catch (Exception e) {
            e.getStackTrace();
        }

        return listboxModiTiPro;
    }

    public void cargarTipoProducto() {
        Option[] options;
        String idTipoPro;
        String nombreTipoProducto;
        ProductosBO producBO = new ProductosBO();
        List<TipoVO> listaTipoProducto = new ArrayList<TipoVO>();
        try {
            listaTipoProducto = producBO.listaTipo();
            options = new Option[listaTipoProducto.size()];

            for (int i = 0; i < listaTipoProducto.size(); i++) {
                idTipoPro = listaTipoProducto.get(i).getIdTipoProducto();
                nombreTipoProducto = listaTipoProducto.get(i).getNombreTipoProducto();
                options[i] = new Option(idTipoPro, nombreTipoProducto);
            } // end for
            optionTipoProducto.setOptions(options);
        } catch (Exception e) {
            e.getStackTrace();
        }
    }

    public void setListboxModiTiPro(HtmlSelectOneListbox hsol) {
        this.listboxModiTiPro = hsol;
    }
    private UISelectItems listbox1SelectItems = new UISelectItems();

    public UISelectItems getListbox1SelectItems() {
        return listbox1SelectItems;
    }

    public void setListbox1SelectItems(UISelectItems uisi) {
        this.listbox1SelectItems = uisi;
    }
    private HtmlSelectOneListbox listboxModiClase = new HtmlSelectOneListbox();

    public HtmlSelectOneListbox getListboxModiClase() {

        listboxModiClase = new HtmlSelectOneListbox();

        String idClaseProducto;
        String nombreClaseProducto;

        ProductosBO productosBO = new ProductosBO();
        List<ClaseProductoVO> listaClase = new ArrayList<ClaseProductoVO>();
        List collection = new ArrayList();
        collection.add(new SelectItem(0, "-Seleccione una clase de producto-"));
        try {
            listaClase = productosBO.listaClase();

            for (int i = 0; i < listaClase.size(); i++) {
                idClaseProducto = listaClase.get(i).getIdClaseProducto();
                nombreClaseProducto = listaClase.get(i).getNombreClaseProducto();

                collection.add(new SelectItem(idClaseProducto, nombreClaseProducto));
            } // end for
            UISelectItems listaMenu = new UISelectItems();
            listaMenu.setValue(collection);
            listboxModiClase.getChildren().add(listaMenu);
        } catch (Exception e) {
            e.getStackTrace();
        }

        return listboxModiClase;
    }

   

    public void cargarClase() {
        Option[] options;
        String idClaseProducto;
        String nombreClaseProducto;
        ProductosBO produBO = new ProductosBO();
        List<ClaseProductoVO> listaClase = new ArrayList<ClaseProductoVO>();
        try {
            listaClase = produBO.listaClase();
            options = new Option[listaClase.size()];
            for (int i = 0; i < listaClase.size(); i++) {
                idClaseProducto = listaClase.get(i).getIdClaseProducto();
                nombreClaseProducto = listaClase.get(i).getNombreClaseProducto();
                options[i] = new Option(idClaseProducto, nombreClaseProducto);
            } // end for
            optionClase.setOptions(options);
        } catch (Exception e) {
            e.getStackTrace();
        }
    }

    public void setListboxModiClase(HtmlSelectOneListbox hsol) {
        this.listboxModiClase = hsol;
    }
    private UISelectItems listbox2SelectItems = new UISelectItems();

    public UISelectItems getListbox2SelectItems() {
        return listbox2SelectItems;
    }

    public void setListbox2SelectItems(UISelectItems uisi) {
        this.listbox2SelectItems = uisi;
    }
    private HtmlSelectOneListbox listboxModiCatego = new HtmlSelectOneListbox();

    public HtmlSelectOneListbox getListboxModiCatego() {
        listboxModiCatego = new HtmlSelectOneListbox();
        String idCategoriaProducto;
        String nombreCategoriaProducto;

        ProductosBO productosBO = new ProductosBO();
        List<CategoriaProductosVO> listaCategoriaPro = new ArrayList<CategoriaProductosVO>();
        List collection = new ArrayList();

        collection.add(new SelectItem(0, "-Seleccione una Categoria-"));
        try {
            listaCategoriaPro = productosBO.listaCategoria();

            for (int i = 0; i < listaCategoriaPro.size(); i++) {
                idCategoriaProducto = listaCategoriaPro.get(i).getIdCategoria();
                nombreCategoriaProducto = listaCategoriaPro.get(i).getNombreCategoria();
                collection.add(new SelectItem(idCategoriaProducto, nombreCategoriaProducto));
            } // end for
            UISelectItems listaMenu = new UISelectItems();
            listaMenu.setValue(collection);
            listboxModiCatego.getChildren().add(listaMenu);
        } catch (Exception e) {
            e.getStackTrace();
        }

        return listboxModiCatego;
    }

     public void cargarCategoria() {
        Option[] options;
        String idCategoriaProducto;
        String nombreCategoriaProducto;
        ProductosBO produBO = new ProductosBO();
        List<CategoriaProductosVO> listaCategoriaPro = new ArrayList<CategoriaProductosVO>();
        try {
            listaCategoriaPro = produBO.listaCategoria();
            options = new Option[listaCategoriaPro.size()];
            for (int i = 0; i < listaCategoriaPro.size(); i++) {
                idCategoriaProducto = listaCategoriaPro.get(i).getIdCategoria();
                nombreCategoriaProducto = listaCategoriaPro.get(i).getNombreCategoria();
                options[i] = new Option(idCategoriaProducto, nombreCategoriaProducto);
            } // end for
            optionCategoria.setOptions(options);
        } catch (Exception e) {
            e.getStackTrace();
        }
    }

    public void setListboxModiCatego(HtmlSelectOneListbox hsol) {
        this.listboxModiCatego = hsol;
    }
    private DefaultSelectItemsArray listbox2DefaultItems1 = new DefaultSelectItemsArray();

    public DefaultSelectItemsArray getListbox2DefaultItems1() {
        return listbox2DefaultItems1;
    }

    public void setListbox2DefaultItems1(DefaultSelectItemsArray dsia) {
        this.listbox2DefaultItems1 = dsia;
    }
    private UISelectItems listbox2SelectItems1 = new UISelectItems();

    public UISelectItems getListbox2SelectItems1() {
        return listbox2SelectItems1;
    }

    public void setListbox2SelectItems1(UISelectItems uisi) {
        this.listbox2SelectItems1 = uisi;
    }
    private DefaultSelectItemsArray listboxModiClaseDefaultItems = new DefaultSelectItemsArray();

    public DefaultSelectItemsArray getListboxModiClaseDefaultItems() {
        return listboxModiClaseDefaultItems;
    }

    public void setListboxModiClaseDefaultItems(DefaultSelectItemsArray dsia) {
        this.listboxModiClaseDefaultItems = dsia;
    }
    private DefaultSelectItemsArray listbox2DefaultItems2 = new DefaultSelectItemsArray();

    public DefaultSelectItemsArray getListbox2DefaultItems2() {
        return listbox2DefaultItems2;
    }

    public void setListbox2DefaultItems2(DefaultSelectItemsArray dsia) {
        this.listbox2DefaultItems2 = dsia;
    }
    private DefaultSelectItemsArray listbox2DefaultItems3 = new DefaultSelectItemsArray();

    public DefaultSelectItemsArray getListbox2DefaultItems3() {
        return listbox2DefaultItems3;
    }

    public void setListbox2DefaultItems3(DefaultSelectItemsArray dsia) {
        this.listbox2DefaultItems3 = dsia;
    }
    private DefaultSelectItemsArray listbox1DefaultItems1 = new DefaultSelectItemsArray();

    public DefaultSelectItemsArray getListbox1DefaultItems1() {
        return listbox1DefaultItems1;
    }

    public void setListbox1DefaultItems1(DefaultSelectItemsArray dsia) {
        this.listbox1DefaultItems1 = dsia;
    }
    private UISelectItems listbox1SelectItems1 = new UISelectItems();

    public UISelectItems getListbox1SelectItems1() {
        return listbox1SelectItems1;
    }

    public void setListbox1SelectItems1(UISelectItems uisi) {
        this.listbox1SelectItems1 = uisi;
    }
    private DefaultSelectItemsArray listboxModiTiProDefaultItems = new DefaultSelectItemsArray();

    public DefaultSelectItemsArray getListboxModiTiProDefaultItems() {
        return listboxModiTiProDefaultItems;
    }

    public void setListboxModiTiProDefaultItems(DefaultSelectItemsArray dsia) {
        this.listboxModiTiProDefaultItems = dsia;
    }
    private DefaultSelectItemsArray listbox1DefaultItems2 = new DefaultSelectItemsArray();

    public DefaultSelectItemsArray getListbox1DefaultItems2() {
        return listbox1DefaultItems2;
    }

    public void setListbox1DefaultItems2(DefaultSelectItemsArray dsia) {
        this.listbox1DefaultItems2 = dsia;
    }
    private DefaultSelectItemsArray listbox1DefaultItems3 = new DefaultSelectItemsArray();

    public DefaultSelectItemsArray getListbox1DefaultItems3() {
        return listbox1DefaultItems3;
    }

    public void setListbox1DefaultItems3(DefaultSelectItemsArray dsia) {
        this.listbox1DefaultItems3 = dsia;
    }
    private static List listaidAtributo;
    private static List valorAtributo;
    private static List nuevoValor;
    private static List viejosValores;
    private static List idAtri;
    private Tab tab2 = new Tab();

    public Tab getTab2() {
        return tab2;
    }

    public void setTab2(Tab t) {
        this.tab2 = t;
    }
    private PanelLayout layoutPanel2 = new PanelLayout();

    public PanelLayout getLayoutPanel2() {
        return layoutPanel2;
    }

    public void setLayoutPanel2(PanelLayout pl) {
        this.layoutPanel2 = pl;
    }
    private Table table1 = new Table();

    public Table getTable1() {
        return table1;
    }

    public void setTable1(Table t) {
        this.table1 = t;
    }
    private TableRowGroup tableRowGroup1 = new TableRowGroup();

    public TableRowGroup getTableRowGroup1() {
        return tableRowGroup1;
    }

    public void setTableRowGroup1(TableRowGroup trg) {
        this.tableRowGroup1 = trg;
    }
    private TableColumn tableColumn1 = new TableColumn();

    public TableColumn getTableColumn1() {
        return tableColumn1;
    }

    public void setTableColumn1(TableColumn tc) {
        this.tableColumn1 = tc;
    }
    private StaticText staticText1 = new StaticText();

    public StaticText getStaticText1() {
        return staticText1;
    }

    public void setStaticText1(StaticText st) {
        this.staticText1 = st;
    }
    private TableColumn tableColumn2 = new TableColumn();

    public TableColumn getTableColumn2() {
        return tableColumn2;
    }

    public void setTableColumn2(TableColumn tc) {
        this.tableColumn2 = tc;
    }
    private TableColumn tableColumn3 = new TableColumn();

    public TableColumn getTableColumn3() {
        return tableColumn3;
    }

    public void setTableColumn3(TableColumn tc) {
        this.tableColumn3 = tc;
    }
    private StaticText staticText2 = new StaticText();

    public StaticText getStaticText2() {
        return staticText2;
    }

    public void setStaticText2(StaticText st) {
        this.staticText2 = st;
    }
    private TableColumn tableColumn4 = new TableColumn();

    public TableColumn getTableColumn4() {
        return tableColumn4;
    }

    public void setTableColumn4(TableColumn tc) {
        this.tableColumn4 = tc;
    }
    private Button buttonModi1 = new Button();

    public Button getButtonModi1() {
        return buttonModi1;
    }

    public void setButtonModi1(Button b) {
        this.buttonModi1 = b;
    }
    private StaticText staticText3 = new StaticText();

    public StaticText getStaticText3() {
        return staticText3;
    }

    public void setStaticText3(StaticText st) {
        this.staticText3 = st;
    }
    private TableRowGroup tableRowGroup2 = new TableRowGroup();

    public TableRowGroup getTableRowGroup2() {
        return tableRowGroup2;
    }

    public void setTableRowGroup2(TableRowGroup trg) {
        this.tableRowGroup2 = trg;
    }
    private TableColumn tableColumn5 = new TableColumn();

    public TableColumn getTableColumn5() {
        return tableColumn5;
    }

    public void setTableColumn5(TableColumn tc) {
        this.tableColumn5 = tc;
    }
    private StaticText staticTextidAtri = new StaticText();

    public StaticText getStaticTextidAtri() {
        return staticTextidAtri;
    }

    public void setStaticTextidAtri(StaticText st) {
        this.staticTextidAtri = st;
    }
    private TableColumn tableColumn6 = new TableColumn();

    public TableColumn getTableColumn6() {
        return tableColumn6;
    }

    public void setTableColumn6(TableColumn tc) {
        this.tableColumn6 = tc;
    }
    private StaticText staticText5 = new StaticText();

    public StaticText getStaticText5() {
        return staticText5;
    }

    public void setStaticText5(StaticText st) {
        this.staticText5 = st;
    }
    private TableColumn tableColumn7 = new TableColumn();

    public TableColumn getTableColumn7() {
        return tableColumn7;
    }

    public void setTableColumn7(TableColumn tc) {
        this.tableColumn7 = tc;
    }
    private TextField textField2 = new TextField();

    public TextField getTextField2() {
        return textField2;
    }

    public void setTextField2(TextField tf) {
        this.textField2 = tf;
    }
    private TableColumn tableColumn8 = new TableColumn();

    public TableColumn getTableColumn8() {
        return tableColumn8;
    }

    public void setTableColumn8(TableColumn tc) {
        this.tableColumn8 = tc;
    }
    private Checkbox checkbox1 = new Checkbox();

    public Checkbox getCheckbox1() {
        return checkbox1;
    }

    public void setCheckbox1(Checkbox c) {
        this.checkbox1 = c;
    }
    private Tab tab3 = new Tab();

    public Tab getTab3() {
        return tab3;
    }

    public void setTab3(Tab t) {
        this.tab3 = t;
    }
    private PanelLayout layoutPanel3 = new PanelLayout();

    public PanelLayout getLayoutPanel3() {
        return layoutPanel3;
    }

    public void setLayoutPanel3(PanelLayout pl) {
        this.layoutPanel3 = pl;
    }
    private HtmlSelectOneListbox listboxEstado1 = new HtmlSelectOneListbox();

    public HtmlSelectOneListbox getListboxEstado1() {
        listboxEstado1 = new HtmlSelectOneListbox();
        String idEstadoP;
        String nombreEstado;

        ProductosBO productosBO = new ProductosBO();

        List<ProductoVO> listaEstado = new ArrayList<ProductoVO>();

        List collection = new ArrayList();
        collection.add(new SelectItem(0, "-Seleccione el Estado-"));
        try {
            listaEstado = productosBO.listaEstado();

            for (int i = 0; i < listaEstado.size(); i++) {
                idEstadoP = listaEstado.get(i).getIdEstado();
                nombreEstado = listaEstado.get(i).getNombreEstado();

                collection.add(new SelectItem(idEstadoP, nombreEstado));
            } // end for
            UISelectItems listaMenu = new UISelectItems();
            listaMenu.setValue(collection);
            listboxEstado1.getChildren().add(listaMenu);
        } catch (Exception e) {
            e.getStackTrace();
        }
        return listboxEstado1;
    }

    public void setListboxEstado1(HtmlSelectOneListbox hsol) {
        this.listboxEstado1 = hsol;
    }
    private Label label1 = new Label();

    public Label getLabel1() {
        return label1;
    }

    public void setLabel1(Label l) {
        this.label1 = l;
    }
    private Button buttonGuardarEstado = new Button();

    public Button getButtonGuardarEstado() {
        return buttonGuardarEstado;
    }

    public void setButtonGuardarEstado(Button b) {
        this.buttonGuardarEstado = b;
    }
    private HtmlMessages messageList1 = new HtmlMessages();

    public HtmlMessages getMessageList1() {
        return messageList1;
    }

    public void setMessageList1(HtmlMessages hm) {
        this.messageList1 = hm;
    }
    private HtmlMessages messageList2 = new HtmlMessages();

    public HtmlMessages getMessageList2() {
        return messageList2;
    }

    public void setMessageList2(HtmlMessages hm) {
        this.messageList2 = hm;
    }
    private HtmlMessages messageList3 = new HtmlMessages();

    public HtmlMessages getMessageList3() {
        return messageList3;
    }

    public void setMessageList3(HtmlMessages hm) {
        this.messageList3 = hm;
    }
    private StaticText staticText4 = new StaticText();

    public StaticText getStaticText4() {
        return staticText4;
    }

    public void setStaticText4(StaticText st) {
        this.staticText4 = st;
    }
    private TextField textField1 = new TextField();

    public TextField getTextField1() {
        return textField1;
    }

    public void setTextField1(TextField tf) {
        this.textField1 = tf;
    }
    private TableColumn tableColumn9 = new TableColumn();

    public TableColumn getTableColumn9() {
        return tableColumn9;
    }

    public void setTableColumn9(TableColumn tc) {
        this.tableColumn9 = tc;
    }
    private StaticText labelNombProduc = new StaticText();

    public StaticText getLabelNombProduc() {
        return labelNombProduc;
    }

    public void setLabelNombProduc(StaticText st) {
        this.labelNombProduc = st;
    }
    private StaticText labelIdProducto = new StaticText();

    public StaticText getLabelIdProducto() {
        return labelIdProducto;
    }

    public void setLabelIdProducto(StaticText st) {
        this.labelIdProducto = st;
    }
    private StaticText labelTipoP = new StaticText();

    public StaticText getLabelTipoP() {
        return labelTipoP;
    }

    public void setLabelTipoP(StaticText st) {
        this.labelTipoP = st;
    }
    private StaticText labelClaseP = new StaticText();

    public StaticText getLabelClaseP() {
        return labelClaseP;
    }

    public void setLabelClaseP(StaticText st) {
        this.labelClaseP = st;
    }
    private StaticText labelNMbreProyec = new StaticText();

    public StaticText getLabelNMbreProyec() {
        return labelNMbreProyec;
    }

    public void setLabelNMbreProyec(StaticText st) {
        this.labelNMbreProyec = st;
    }
    private StaticText labelCategoriaP = new StaticText();

    public StaticText getLabelCategoriaP() {
        return labelCategoriaP;
    }

    public void setLabelCategoriaP(StaticText st) {
        this.labelCategoriaP = st;
    }
    private StaticText labelRegistro = new StaticText();

    public StaticText getLabelRegistro() {
        return labelRegistro;
    }

    public void setLabelRegistro(StaticText st) {
        this.labelRegistro = st;
    }
    private StaticText labelEstado1 = new StaticText();

    public StaticText getLabelEstado1() {
        return labelEstado1;
    }

    public void setLabelEstado1(StaticText st) {
        this.labelEstado1 = st;
    }
    private HtmlPanelGrid gridPanelPrincipal = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanelPrincipal() {
        return gridPanelPrincipal;
    }

    public void setGridPanelPrincipal(HtmlPanelGrid hpg) {
        this.gridPanelPrincipal = hpg;
    }
    private HtmlPanelGrid gridPanel1 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel1() {
        return gridPanel1;
    }

    public void setGridPanel1(HtmlPanelGrid hpg) {
        this.gridPanel1 = hpg;
    }
    private Label labelIDProducto = new Label();

    public Label getLabelIDProducto() {
        return labelIDProducto;
    }

    public void setLabelIDProducto(Label l) {
        this.labelIDProducto = l;
    }
    private HtmlPanelGrid gridPanel4 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel4() {
        return gridPanel4;
    }

    public void setGridPanel4(HtmlPanelGrid hpg) {
        this.gridPanel4 = hpg;
    }
    private HtmlPanelGrid gridPanel6 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel6() {
        return gridPanel6;
    }

    public void setGridPanel6(HtmlPanelGrid hpg) {
        this.gridPanel6 = hpg;
    }
    private HtmlPanelGrid gridPanel7 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel7() {
        return gridPanel7;
    }

    public void setGridPanel7(HtmlPanelGrid hpg) {
        this.gridPanel7 = hpg;
    }
    private HtmlPanelGrid gridPanelBotones = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanelBotones() {
        return gridPanelBotones;
    }

    public void setGridPanelBotones(HtmlPanelGrid hpg) {
        this.gridPanelBotones = hpg;
    }
    private HtmlPanelGrid gridPanelAtributosP = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanelAtributosP() {
        return gridPanelAtributosP;
    }

    public void setGridPanelAtributosP(HtmlPanelGrid hpg) {
        this.gridPanelAtributosP = hpg;
    }
    private HtmlPanelGrid gridPanel3 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel3() {
        return gridPanel3;
    }

    public void setGridPanel3(HtmlPanelGrid hpg) {
        this.gridPanel3 = hpg;
    }
    private HtmlPanelGrid gridPanelInfo = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanelInfo() {
        return gridPanelInfo;
    }

    public void setGridPanelInfo(HtmlPanelGrid hpg) {
        this.gridPanelInfo = hpg;
    }
    // </editor-fold>

    /**
     * <p>Construct a new Page bean instance.</p>
     */
    public Modificar_Producto() {
        this.cargarVariablesSession();
    }

    private void cargarVariablesSession(){

        if(this.getSession().getAttribute(ID_SESSION_MODIFICAR_PRODUCTO+"listaAuxAtributos")!=null){
            this.setListaAuxAtributos((List<AtributosVO>) this.getSession().getAttribute(ID_SESSION_MODIFICAR_PRODUCTO+"listaAuxAtributos"));
        }
    }

    /**
     * <p>Callback method that is called whenever a page is navigated to,
     * either directly via a URL, or indirectly via page navigation.
     * Customize this method to acquire resources that will be needed
     * for event handlers and lifecycle methods, whether or not this
     * page is performing post back processing.</p>
     * 
     * <p>Note that, if the current request is a postback, the property
     * values of the components do <strong>not</strong> represent any
     * values submitted with this request.  Instead, they represent the
     * property values that were saved for this view when it was rendered.</p>
     */
    @Override
    public void init() {
        // Perform initializations inherited from our superclass
        super.init();
        // Perform application initialization that must complete
        // *before* managed components are initialized
        // TODO - add your own initialiation code here

        // <editor-fold defaultstate="collapsed" desc="Managed Component Initialization">
        // Initialize automatically managed components
        // *Note* - this logic should NOT be modified
        try {
            _init();
        } catch (Exception e) {
            log("Modificar_Producto Initialization Failure", e);
            throw e instanceof FacesException ? (FacesException) e : new FacesException(e);
        }

        // </editor-fold>
        // Perform application initialization that must complete
        // *after* managed components are initialized
        // TODO - add your own initialization code here
        String idProducto = "", nombrePro = "";
        cargarTipoProducto();
        cargarClase();
        cargarCategoria();
        productoVO = getRequestBean1().getProductoVO();

        llenarCampos(productoVO);

        if (listaidAtributo == null) {
            listaidAtributo = new ArrayList();
        }
        if (valorAtributo == null) {
            valorAtributo = new ArrayList();
        }
        if (nuevoValor == null) {
            valorAtributo = new ArrayList();
        }
        if (viejosValores == null || idAtri == null) {
            viejosValores = new ArrayList();
        }
        idAtri = new ArrayList();

    }

    /**
     * <p>Callback method that is called after the component tree has been
     * restored, but before any event processing takes place.  This method
     * will <strong>only</strong> be called on a postback request that
     * is processing a form submit.  Customize this method to allocate
     * resources that will be required in your event handlers.</p>
     */
    @Override
    public void preprocess() {
    }

    /**
     * <p>Callback method that is called just before rendering takes place.
     * This method will <strong>only</strong> be called for the page that
     * will actually be rendered (and not, for example, on a page that
     * handled a postback and then navigated to a different page).  Customize
     * this method to allocate resources that will be required for rendering
     * this page.</p>
     */
    @Override
    public void prerender() {
    }

    /**
     * <p>Callback method that is called after rendering is completed for
     * this request, if <code>init()</code> was called (regardless of whether
     * or not this was the page that was actually rendered).  Customize this
     * method to release resources acquired in the <code>init()</code>,
     * <code>preprocess()</code>, or <code>prerender()</code> methods (or
     * acquired during execution of an event handler).</p>
     */
    @Override
    public void destroy() {
    }

    /**
     * <p>Return a reference to the scoped data bean.</p>
     *
     * @return reference to the scoped data bean
     */
    protected RequestBean1 getRequestBean1() {
        return (RequestBean1) getBean("RequestBean1");
    }

    /**
     * <p>Return a reference to the scoped data bean.</p>
     *
     * @return reference to the scoped data bean
     */
    protected SessionBean1 getSessionBean1() {
        return (SessionBean1) getBean("SessionBean1");
    }

    /**
     * <p>Return a reference to the scoped data bean.</p>
     *
     * @return reference to the scoped data bean
     */
    protected ApplicationBean1 getApplicationBean1() {
        return (ApplicationBean1) getBean("ApplicationBean1");
    }
    ProductosBO productosBO;
    ProductoVO productoVO;
    AtributosBO atributosBO;
    AtributosVO atributosVO;
    String idEstado = "", descripcionProducto = "", idTipoProducto = "", idCategoria = "",
            idClase = "", resultadosEsperados = "", sectoresBeneficiados = "", idTipoPropiedad = "",
            resultado = "", aux = "", idProducto = "", tipoProducto = "";
    int idProyecto = 0;
    Date fechanueva = null;

    public String buttonGuardar_action() {
        // TODO: Process the action. Return value is a navigation
        // case name where null will return to the same page.

        java.util.Date fechaModifica = new java.util.Date();
        String idProducto = "";
        String mostrar = "";

        try {

            productosBO = new ProductosBO();
            productoVO = new ProductoVO();
            fechaModifica = new Date(fechaModifica.getTime());
            fechanueva = new Date(fechaModifica.getTime());
            descripcionProducto = (String) textAreaDesModi.getValue();
            idTipoProducto = (String) dropTipoProducto.getValue();
            idCategoria = (String) dropCategoria.getValue();
            idClase = (String) dropClase.getValue();
            resultadosEsperados = (String) textAreaResutModi.getValue();
            sectoresBeneficiados = (String) textAreaBeneModi.getValue();
            idEstado = (String) listboxEstado1.getValue();

            if (descripcionProducto == null || descripcionProducto.equals("")) {
                error("Por favor digite la descripcion del Producto ");
                return null;
            } else if (idTipoProducto == null) {
                error("Por favor Seleccione el tipo de Producto");
                return null;
            } else if (idCategoria == null) {
                error("Por favor Seleccione una categoria");
                return null;
            } else if (idClase == null) {
                error("Por favor Seleccione una clase");
                return null;
            } else if (resultadosEsperados == null) {
                error("Por favor digite los resultados esperados");
                return null;
            } else if (sectoresBeneficiados == null) {
                error("Por favor digite los sectores beneficiados");
                return null;
            }

            productoVO.setIdProducto(this.getLabelIdProducto().getValue().toString());
            productoVO.setIdCategoria(idCategoria);
            productoVO.setIdClaseP(idClase);
            productoVO.setDescripcion(descripcionProducto);
            productoVO.setResultado(resultadosEsperados);
            productoVO.setSectoresBenef(sectoresBeneficiados);
            productoVO.setFModificacion(fechanueva);
            productoVO.setIdTipoP(idTipoProducto);
            productoVO.setIdEstado(idEstado);

            resultado = productosBO.modificarProduc(productoVO);

            if (resultado.equals("PRODUCTO MODIFICADO CORRECTAMENTE")) {
                info(resultado);
            } else {
                error("Error al modificar el producto");
                return null;
            }
        } catch (Exception e) {
            error("El producto no se puedo Ingresar");
        }
        return null;
    }

    public String consultarAtributos() {

        String resultado = null, nombreAtributo = "";
        tipoProducto = productoVO.getIdTipoP();
        idProducto = (String) labelIdProducto.getText();
        List<AtributosVO> listAtri = new ArrayList<AtributosVO>();
        String id = (String) labelIdProducto.getText();
        try {
            atributosVO = new AtributosVO();
            atributosBO = new AtributosBO();
            listAtri = new ArrayList<AtributosVO>();
            tipoProducto = idProducto;

            atributosVO.setIdProducto(tipoProducto);
            atributosVO.setIdTipoProducto(this.getLabelIDProducto().getText().toString());
            listaAuxAtributos = atributosBO.consultarAtributosAnterio(atributosVO);
            this.getSession().setAttribute(ID_SESSION_MODIFICAR_PRODUCTO+"listaAuxAtributos", this.getListaAuxAtributos());
          /*  getSessionBean1().addListaAtributosViejos(listAtri);*/

        } catch (Exception e) {
            error("Error al ingresar el Atributo.");
        }
        return null;
    }

    public String consultarAtributosNuevos() {

        idProducto = productoVO.getIdProducto();
        idTipoProducto = (String) labelIdProducto.getText();
        List<AtributosVO> listAtri = new ArrayList<AtributosVO>();
        String id = (String) labelIdProducto.getText();
        try {
            atributosVO = new AtributosVO();
            atributosBO = new AtributosBO();
            listAtri = new ArrayList<AtributosVO>();
            atributosVO.setIdTipoProducto(idTipoProducto);
            listAtri = atributosBO.consultarAtributos(atributosVO);
            getSessionBean1().addListaAtributos(listAtri);

        } catch (Exception e) {
            error("Error al ingresar el Atributo.");
        }
        return null;
    }

    public void checkbox1_processValueChange(ValueChangeEvent event) {

        String prueba = "", idAtributo = "", valor = "";
        String requerido = "";
        List<AtributosVO> listaValores = new ArrayList<AtributosVO>();

        requerido = (String) event.getNewValue();

        try {
            atributosVO = new AtributosVO();
            atributosBO = new AtributosBO();
            prueba = requerido;
            if (prueba.equals("true")) {
                atributosVO = new AtributosVO();
                idAtributo = (String) staticTextidAtri.getValue();
                valor = (String) textField2.getValue();

                listaidAtributo.add(idAtributo);
                valorAtributo.add(valor);
                prueba = "false";
            }
        } catch (Exception e) {
            e.getStackTrace();
        }
    }

    public String buttonModi_action() throws Exception {

        String nombreidROL = "", nombre = "";
        String aux = "", valor = "", idAtribu;
        try {

            atributosVO = new AtributosVO();
            atributosBO = new AtributosBO();
            idAtribu = (String) staticText2.getValue();
            valor = (String) textField1.getValue();
            atributosVO.setIdAtributoProducto(idAtribu);
            atributosVO.setValor(valor);
            atributosVO.setIdProducto(this.getLabelIdProducto().getText().toString());
            if(valor == null || valor.equals("")){
                error("Si desea modificar el valor de este atributo, por favor digite el nuevo valor.");
                return null;
            }
            aux = atributosBO.modificarAtributosProducto(atributosVO);
            info(aux);
            consultarAtributos();

        } catch (Exception e) {
            error("No pudo ser Modificado");
        }
        return "ok";
    }

    public String buttonGuarAtribu_action() {
        // TODO: Process the action. Return value is a navigation
        // case name where null will return to the same page.
        String idProducto = "8";

        try {

            atributosVO = new AtributosVO();
            atributosBO = new AtributosBO();

            for (int i = 0; i < valorAtributo.size(); i++) {

                String mos = "";
                String idAtributo = (String) listaidAtributo.get(i);
                String valor = (String) valorAtributo.get(i);

                atributosVO.setIdAtributoProducto(idAtributo);
                atributosVO.setValor(valor);
                atributosVO.setIdProducto(idProducto);

                mos = atributosBO.insetarAtributosProducto(atributosVO);

                if (!mos.equals("") || mos != null) {
                    info("Se inserto correctamente");
                }
            }
        } catch (Exception e) {
        }

        return null;
    }

    public String buttonGuardarEstado_action() {
        String idProducto = "", mos = "";
        try {

            productoVO = new ProductoVO();
            productosBO = new ProductosBO();
            String idEstado = (String) listboxEstado1.getValue();
            idProducto = (String) labelIdProducto.getValue();
            productoVO.setIdEstado(idEstado);
            productoVO.setIdProducto(idProducto);
            mos = productosBO.modificarEstadoProduc(productoVO);
            info(mos);

        } catch (Exception e) {
        }

        return null;
    }

    public String buttonVolver_action() {
        return "consultarProducto";
    }

    private void llenarCampos(ProductoVO productoVO) {
        labelIdProducto.setText(productoVO.getIdProducto());
        labelNombProduc.setText(productoVO.getNombreProducto());
        labelNMbreProyec.setText(productoVO.getTituloProyecto());
        labelEstado1.setText(productoVO.getNombreEstado());
        labelCategoriaP.setText(productoVO.getNombreCategoria());
        labelClaseP.setText(productoVO.getNombreClase());
        labelRegistro.setText(productoVO.getFRegistro());
        labelTipoP.setText(productoVO.getNombreTipoProducto());
        textAreaDesModi.setText(productoVO.getDescripcion());
        textAreaResutModi.setText(productoVO.getResultado());
        dropCategoria.setValue(productoVO.getIdCategoria());
        dropClase.setValue(productoVO.getIdClaseP());
        dropTipoProducto.setValue(productoVO.getIdTipoP());
        textAreaBeneModi.setValue(productoVO.getSectoresBenef());
    }

    public String tab2_action() {
        consultarAtributos();
        consultarAtributosNuevos();
        return null;
    }

    public String tab1_action() {
        return null;
    }

    public DropDown getDropCategoria() {
        return dropCategoria;
    }

    public void setDropCategoria(DropDown dropCategoria) {
        this.dropCategoria = dropCategoria;
    }

    public DropDown getDropClase() {
        return dropClase;
    }

    public void setDropClase(DropDown dropClase) {
        this.dropClase = dropClase;
    }

    public DropDown getDropTipoProducto() {
        return dropTipoProducto;
    }

    public void setDropTipoProducto(DropDown dropTipoProducto) {
        this.dropTipoProducto = dropTipoProducto;
    }

    public SingleSelectOptionsList getOptionCategoria() {
        return optionCategoria;
    }

    public void setOptionCategoria(SingleSelectOptionsList optionCategoria) {
        this.optionCategoria = optionCategoria;
    }

    public SingleSelectOptionsList getOptionClase() {
        return optionClase;
    }

    public void setOptionClase(SingleSelectOptionsList optionClase) {
        this.optionClase = optionClase;
    }

    public SingleSelectOptionsList getOptionTipoProducto() {
        return optionTipoProducto;
    }

    public void setOptionTipoProducto(SingleSelectOptionsList optionTipoProducto) {
        this.optionTipoProducto = optionTipoProducto;
    }

    public List<AtributosVO> getListaAuxAtributos() {
        return listaAuxAtributos;
    }

    public void setListaAuxAtributos(List<AtributosVO> listaAuxAtributos) {
        this.listaAuxAtributos = listaAuxAtributos;
    }

    public HttpSession getSession() {
        return (HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(true);
    }

    public void setSession(HttpSession session) {
        this.session = session;
    }


}